<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
    <script src="./config/throttle.js"></script>
</head>
<body>
    <div id="app">
        <input type="text" v-model="msg" >
        <p>{{msg}}</p>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                msg: ""
            },
            watch:{
                msg:throttle(function(){
                    throttle(this.getSearch(this.msg))
                })
            },
            methods:{
                getSearch(val){
                    var url = `http://122.112.161.135:3000/search?keywords=${val}`;
                    console.log(url);
                    axios.get(`http://122.112.161.135:3000/search?keywords=${val}`).then(res=>{
                        console.log(res.data.result)
                    })
                }
            }
        })
    </script>
</body>
</html>